package edu.practice;

import java.util.*;
class Student implements Comparable<Student>{
    private String name,id;
    private int subject=1;
    private int score;
    private double sum=0;
    Student(){}
    Student(String name,String id,int score){
        this.name=name;
        this.id=id;
        this.score=score;
    }
    public String getid(){
        return this.id;
    }
    public void subjectadd() {
        this.subject++;
    }
    public void scoreadd(int score){
        this.score=this.score+score;
    }
    public String getname() {
        return this.name;
    }
    public void sum() {
        this.sum=this.score/this.subject;
    }
    /*public int rescore() {
         return this.score;
     }*/
   /* public double getsum(){
        return this.sum;
    }*/
    public int compareTo(Student o1){
        Student one = (Student) o1;
        if(this.sum-one.sum!=0)
            return (int)(one.sum-this.sum);
        else
            return this.id.compareTo(one.id);
    }
}
public class sdust{
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        List<Student> list =new ArrayList<Student>();
        int i,flag=0;
        String k;
        String[] and =new String[5];

        while(sc.hasNext())
        {
            k=sc.next();
            and=k.split(",");
            if(k.compareTo("exit")==0)
                break;
            for(i=0;i<list.size();i++)
            {
                if(list.get(i).getid().compareTo(and[1])==0)
                {
                    flag=1;
                    break;
                }
            }
            if(flag==1)
            {
                list.get(i).subjectadd();
                list.get(i).scoreadd(Integer.parseInt(and[3]));
            }
            else
            {
                list.add(new Student(and[0],and[1],Integer.parseInt(and[3])));
            }
            flag=0;
        }
        for(i=0;i<list.size();i++)
            list.get(i).sum();
        Collections.sort(list);
        for(i=0;i<list.size();i++)
        {

            System.out.println("No"+(i+1)+":"+list.get(i).getid()+","+list.get(i).getname());
            //System.out.println(list.get(i).rescore());
        }

    }
}
